package com.waverider.promotion.model;

import java.util.List;

public class ResultModel<T> extends BaseModel 
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -5335097491415015552L;

	private BaseQueryModel queryModel;
	
	private Long totalItem;
	private Long totalPage;
	
	private List<T> itemList;
	
	
	public static <T> ResultModel<T> buildResultModel(BaseQueryModel queryModel, List<T> itemList, Long totalItem)
	{
		ResultModel<T> resultModel = new ResultModel<T>();
		resultModel.setQueryModel(queryModel);
		resultModel.setItemList(itemList);
		resultModel.setTotalItem(totalItem);
		queryModel.setTotalItem(totalItem.intValue());
		return resultModel;
	}

	public BaseQueryModel getQueryModel()
	{
		return queryModel;
	}

	public Long getTotalItem()
	{
		return totalItem;
	}

	public Long getTotalPage()
	{
		return totalPage;
	}

	public List<T> getItemList()
	{
		return itemList;
	}

	public void setQueryModel(BaseQueryModel queryModel)
	{
		this.queryModel = queryModel;
	}

	public void setTotalItem(Long totalItem)
	{
		this.totalItem = totalItem;
	}

	public void setTotalPage(Long totalPage)
	{
		this.totalPage = totalPage;
	}

	public void setItemList(List<T> itemList)
	{
		this.itemList = itemList;
	}
}
